package com.earl.qrcode.service;

import java.io.IOException;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.earl.qrcode.entitys.Goods;
import com.earl.qrcode.entitys.blackqacode;
import com.earl.qrcode.repository.BlackqacodeRepository;
import com.earl.qrcode.repository.GoodsRepository;

@Service
public class GoodsService extends MyService {

	@Autowired
	private GoodsRepository goodsRepository;

	@Autowired
	private  BlackqacodeRepository blackqacode;

	
	
	@Transactional
	public String saveGoods(Goods goods, String modeName) throws IOException {
		Goods goodsWithId = goodsRepository.save(goods);

		return getDomainName() + "/goods/" + modeName + "/" +goodsWithId.getGoodsId();
	}

	public Goods getGoodsById(Integer id) {
		return goodsRepository.findOne(id);
	}

	

	public void savablackqacode(String blackqacodeName,int whiteId,int qrcodeId){
		blackqacode blackqacodea=new blackqacode(blackqacodeName, whiteId,qrcodeId);
		  blackqacode.save(blackqacodea);
	}
	
}
